package com.neusoft.resturant.service.impl;

import com.neusoft.resturant.entity.ResCarts;
import com.neusoft.resturant.entity.ResCollect;
import com.neusoft.resturant.mapper.ResCartsMapper;
import com.neusoft.resturant.service.IResCartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @program: resturant
 * @description:
 * @author: lydms
 * @create: 2023-12-16 20:22
 **/

@Service
public class ResCartsServiceImpl implements IResCartsService {

    @Autowired
    private ResCartsMapper resCartsMapper;

    @Override
    public List<ResCollect> selectResCartsList() {

        return resCartsMapper.selectResCartsList();
    }


    /**
     * 添加商品到购物车
     * @param resCarts
     */
    @Override
    public void addResCart(ResCarts resCarts) {
        Date date = new Date(System.currentTimeMillis());
        resCarts.setCreateTime(date);
        resCarts.setUpdateTime(date);
        resCartsMapper.addResCart(resCarts);
    }

    /**
     * 批量删除购物车
     *
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public void deleteResCartsByIds(Long[] ids)
    {
        resCartsMapper.deleteResCartsByIds(ids);
    }

}
